<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>罗马数转整数</title>
</head>
<body>
  <script>
    function fn(s) {
      let obj = {
        I: 1,
        V: 5,
        X: 10,
        L: 50,
        C: 100,
        D: 500,
        M: 1000,
      }
      let num = 0
      for(let i = 0; i < s.length; i++) {
        // console.log(obj[s[i]])
        num += obj[s[i]]
      }
      return num
    }
    console.log(fn('XX'))
  </script>
</body>
</html>